package cc.rengu.redp.bizimpl.upmp.controller;


import cc.rengu.redp.bizimpl.upmp.bean.McGrpInfo;
import cc.rengu.redp.bizimpl.upmp.common.BusinessContainer;
import cc.rengu.redp.bizimpl.upmp.dao.BankLevelQuotalManagerMapper;
import cc.rengu.redp.bizimpl.upmp.domain.BTxnLimitCfg;
import cc.rengu.redp.bizimpl.upmp.domain.IndustryInfo;
import cc.rengu.redp.bizimpl.upmp.domain.UpmpOrganization;
import cc.rengu.redp.bizimpl.upmp.domain.UpmpSysParam;
import cc.rengu.redp.bizimpl.upmp.service.BTxnLimitCfgService;
import cc.rengu.redp.bizimpl.upmp.service.BankLevelQuotaManagetService;
import cc.rengu.redp.bizimpl.upmp.service.IUpmpOrganizationService;
import cc.rengu.redp.bizimpl.upmp.service.IUpmpSysParamService;
import cc.rengu.redp.bizimpl.upmp.vo.OperationResult;
import cc.rengu.redp.bizimpl.upmp.vo.UpmpUserInfoVO;
import cc.rengu.redp.bizimpl.utils.Common;
import cc.rengu.redp.bizimpl.utils.CommonUtils;
import cc.rengu.redp.bizimpl.utils.ExtPropertyPlaceholderConfigurer;
import cc.rengu.redp.bizimpl.utils.RedpUpmpUtil;
import cc.rengu.redp.common.domain.QueryRequest;
import cc.rengu.redp.common.exception.RedpException;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.apache.commons.io.IOUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

//@MetaData("商户组别限额管理")
@Validated
@RestController
@Api(tags = "商户限额管理:商户组别限额管理")
@RequestMapping(value = "/admin/quota/bankLevelManager")
public class BankLevelQuotaManagetController {
    private final static Logger log = LoggerFactory.getLogger(BankLevelQuotaManagetController.class);
    @Resource
    private ResourceLoader resourceLoader;
        @Autowired
        private BankLevelQuotaManagetService bankLevelQuotaManagetService;
        @Autowired
        private BankLevelQuotalManagerMapper bankLevelQuotalManagerMapper;
        @Autowired
        private IUpmpOrganizationService iUpmpOrganizationService;
        @Autowired
        private BTxnLimitCfgService bTxnLimitCfgService;
        @Autowired
        private IUpmpSysParamService upmpSysParamService;
    @Autowired(required = false)
    private ExtPropertyPlaceholderConfigurer extPropertyPlaceholderConfigurer;
    /**
     * 获取商户组别限额信息配置pageList
     */
//    @RequiresPermissions("商户限额管理:商户组别限额管理")
    @RequiresPermissions("bankLevelManager:view")
    @ResponseBody
    @RequestMapping(value = "", method = RequestMethod.GET)
    public List<BTxnLimitCfg> getBankLevelQuotaList(HttpServletRequest request) throws RedpException {
        List<BTxnLimitCfg> merchantLeveList = null;
        try {
            merchantLeveList = bankLevelQuotaManagetService.getBankLevelQuotaList(request);
        } catch (Exception e) {
            log.error("获取限额信息时系统异常:[{}]", e);
            throw new RedpException("获取限额信息时系统异常");
        }

        return merchantLeveList;
    }

    /**
     * 根据商户号或商户名称筛选 正式 商户列表数据
     *
     * @param request 必须包含instId
     * @return
     */
    @GetMapping(value = "/mchntFormalSelect2List")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "q", value = "参数", required = true, dataType = "String")
    })
    public List<BTxnLimitCfg> mchntFormalSelect2List(String q, QueryRequest request) throws RedpException {
        q=q.replaceAll("&amp;", "&");
        String[] param = q.split("&");
        return bankLevelQuotalManagerMapper.mchntFormalSelect2List(param[2]);
    }
    /**
     * 新增银行级 商户组别MCC限额
     */
   // @Token(remove = true)
    @RequiresPermissions("bankLevelManager:add")
    @ResponseBody
    @RequestMapping(value = "saveMerMccQuota", method = RequestMethod.POST)
    public OperationResult addBankMCCquota(BTxnLimitCfg txnLimitCfgVo, HttpServletRequest request) {
        try {
            verfiyData(txnLimitCfgVo);
            bankLevelQuotaManagetService.addBankMCCquota(txnLimitCfgVo, request);
        } catch (Exception e) {
            log.error("保存限额信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额信息时系统异常:" + e.getMessage());
        }
        return OperationResult.buildSuccessResult();
    }
    //校验新增
    private void verfiyData(BTxnLimitCfg txnLimitCfgVo) throws RedpException {
        String dayLimitAmt = txnLimitCfgVo.getDayLimitAmt();
        String monthLimitAmt = txnLimitCfgVo.getMonthLimitAmt();
        String dayLimitLoanAmt = txnLimitCfgVo.getDayLimitLoanAmt();
        String monthLimitLoanAmt = txnLimitCfgVo.getMonthLimitLoanAmt();
        String singleLimitLoanMaxAmt = txnLimitCfgVo.getSingleLimitLoanMaxAmt();
        String dayLimitCreditAmt = txnLimitCfgVo.getDayLimitCreditAmt();
        String monthLimitCreditAmt = txnLimitCfgVo.getMonthLimitCreditAmt();
        String singleLimitCreditMaxAmt = txnLimitCfgVo.getSingleLimitCreditMaxAmt();

        if (StringUtils.isNotBlank(dayLimitAmt) && StringUtils.isNotBlank(monthLimitAmt)) {
            if (Double.parseDouble(dayLimitAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("日累计限额不能大于月累计限额");
            }
        }
        //------日累计限额

        if (StringUtils.isNotBlank(dayLimitAmt) && StringUtils.isNotBlank(dayLimitLoanAmt)) {
            if (Double.parseDouble(dayLimitLoanAmt) > Double.parseDouble(dayLimitAmt)) {
                throw new RedpException("日累计借记限额不能大于日累计限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitAmt) && StringUtils.isNotBlank(singleLimitLoanMaxAmt)) {
            if (Double.parseDouble(singleLimitLoanMaxAmt) > Double.parseDouble(dayLimitAmt)) {
                throw new RedpException("单笔借记限额不能大于日累计限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitAmt) && StringUtils.isNotBlank(dayLimitCreditAmt)) {
            if (Double.parseDouble(dayLimitCreditAmt) > Double.parseDouble(dayLimitAmt)) {
                throw new RedpException("日累计贷记限额不能大于日累计限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitAmt) && StringUtils.isNotBlank(singleLimitCreditMaxAmt)) {
            if (Double.parseDouble(singleLimitCreditMaxAmt) > Double.parseDouble(dayLimitAmt)) {
                throw new RedpException("单笔贷记限额不能大于日累计限额");
            }
        }
        //-----月累计限额
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(monthLimitLoanAmt)) {
            if (Double.parseDouble(monthLimitLoanAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("月累计借记限额不能大于月累计限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(dayLimitLoanAmt)) {
            if (Double.parseDouble(dayLimitLoanAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("日累计借记限额不能大于月累计限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(singleLimitLoanMaxAmt)) {
            if (Double.parseDouble(singleLimitLoanMaxAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("单笔借记限额不能大于月累计限额");
            }
        }


        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(monthLimitCreditAmt)) {
            if (Double.parseDouble(monthLimitCreditAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("月累计贷记限额不能大于月累计限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(dayLimitCreditAmt)) {
            if (Double.parseDouble(dayLimitCreditAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("日累计贷记限额不能大于月累计限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(singleLimitCreditMaxAmt)) {
            if (Double.parseDouble(singleLimitCreditMaxAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("单笔贷记限额不能大于月累计限额");
            }
        }

        //-------借记
        if (StringUtils.isNotBlank(monthLimitLoanAmt) && StringUtils.isNotBlank(dayLimitLoanAmt)) {
            if (Double.parseDouble(dayLimitLoanAmt) > Double.parseDouble(monthLimitLoanAmt)) {
                throw new RedpException("日累计借记限额不能大于月累计借记限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitLoanAmt) && StringUtils.isNotBlank(singleLimitLoanMaxAmt)) {
            if (Double.parseDouble(singleLimitLoanMaxAmt) > Double.parseDouble(monthLimitLoanAmt)) {
                throw new RedpException("单笔借记限额不能大于月累计借记限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitLoanAmt) && StringUtils.isNotBlank(singleLimitLoanMaxAmt)) {
            if (Double.parseDouble(singleLimitLoanMaxAmt) > Double.parseDouble(dayLimitLoanAmt)) {
                throw new RedpException("单笔借记限额不能大于日累计借记限额");
            }
        }
        //-------贷记
        if (StringUtils.isNotBlank(monthLimitCreditAmt) && StringUtils.isNotBlank(dayLimitCreditAmt)) {
            if (Double.parseDouble(dayLimitCreditAmt) > Double.parseDouble(monthLimitCreditAmt)) {
                throw new RedpException("日累计贷记限额不能大于月累计贷记限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitCreditAmt) && StringUtils.isNotBlank(singleLimitCreditMaxAmt)) {
            if (Double.parseDouble(singleLimitCreditMaxAmt) > Double.parseDouble(monthLimitCreditAmt)) {
                throw new RedpException("单笔贷记限额不能大于月累计贷记限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitCreditAmt) && StringUtils.isNotBlank(singleLimitCreditMaxAmt)) {
            if (Double.parseDouble(singleLimitCreditMaxAmt) > Double.parseDouble(dayLimitCreditAmt)) {
                throw new RedpException("单笔贷记限额不能大于日累计贷记限额");
            }
        }
    }
    /**
     * 停用银行级 商户组别MCC限额
     */
    @RequiresPermissions("bankLevelManager:stop")
    @ResponseBody
    @RequestMapping(value = "/stopBankMCCquota", method = RequestMethod.PUT)
    public OperationResult stopBankMCCquota(HttpServletRequest request, BTxnLimitCfg req) {

        try {
            bankLevelQuotaManagetService.stopBankMCCquota(request, req);
        } catch (Exception e) {
            log.error("保存限额操作信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额操作信息时系统异常:" + e.getMessage());
        }
        return OperationResult.buildSuccessResult();
    }
    /**
     * 启用银行级 商户组别MCC限额
     */
    @RequiresPermissions("bankLevelManager:use")
    @ResponseBody
    @RequestMapping(value = "/startBankMCCquota", method = RequestMethod.PUT)
    public OperationResult startBankMCCquota(HttpServletRequest request, BTxnLimitCfg req) {

        try {
            bankLevelQuotaManagetService.startBankMCCquota(request, req);
        } catch (Exception e) {
            log.error("保存限额操作信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额操作信息时系统异常:" + e.getMessage());

        }
        return OperationResult.buildSuccessResult();
    }
    /**
     * 注销银行级 商户组别MCC限额
     */
    @RequiresPermissions("bankLevelManager:cancel")
    @ResponseBody
    @RequestMapping(value = "/deleteBankMCCquota", method = RequestMethod.PUT)
    public OperationResult deleteBankMCCquota(HttpServletRequest request, BTxnLimitCfg req) {

        try {
            bankLevelQuotaManagetService.deleteBankMCCquota(request, req);
        } catch (Exception e) {
            log.error("保存限额操作信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额操作信息时系统异常:" + e.getMessage());
        }
        return OperationResult.buildSuccessResult();
    }

    /**
     * 修改银行级 商户组别MCC限额
     */
    @RequiresPermissions("bankLevelManager:edit")
    @ResponseBody
    @RequestMapping(value = "editBankMCCquota", method = RequestMethod.PUT)
    public OperationResult editBankMCCquota(BTxnLimitCfg txnLimitCfgVo, HttpServletRequest request) {

        try {
            verfiyData(txnLimitCfgVo);
            bankLevelQuotaManagetService.editBankMCCquota(txnLimitCfgVo, request);
        } catch (Exception e) {
            log.error("保存限额操作信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额操作信息时系统异常:" + e.getMessage());
        }
        return OperationResult.buildSuccessResult();
    }

    /**
     * 生成 Excel导入模板
     *
     * @param response
     */
    @PostMapping("getExcel")
    public void generateImportTemplate(HttpServletResponse response) {
        InputStream inputStream = null;
        ServletOutputStream servletOutputStream = null;
        try {
            String filename = "mchntGroupQuotaImportTemplate.xlsx";
            String path = "template/mchntGroupQuotaImportTemplate.xlsx";
            org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:" + path);

            response.setContentType("application/vnd.ms-excel");
            response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
            response.addHeader("charset", "utf-8");
            response.addHeader("Pragma", "no-cache");
            String encodeName = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString());
            response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName);

            inputStream = resource.getInputStream();
            servletOutputStream = response.getOutputStream();
            IOUtils.copy(inputStream, servletOutputStream);
            response.flushBuffer();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (servletOutputStream != null) {
                    servletOutputStream.close();
                }
                if (inputStream != null) {
                    inputStream.close();
                }
                // jvm的垃圾回收
                System.gc();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    /**
     * 导入Excel数据
     *
     * @param excelFile
     * @return
     * @throws Exception
     */
    @RequiresPermissions("bankLevelManager:import")
    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    @ResponseBody
    public OperationResult getDataFromExcel(@RequestParam("file") MultipartFile excelFile, @RequestParam("instId") String InstId) throws Exception {


        try {
            String originalFilename = excelFile.getOriginalFilename();
            if (!originalFilename.endsWith(".xls") && !originalFilename.endsWith(".xlsx")) {
                log.error("文件不是excel类型");
                return OperationResult.buildFailureResult("文件不是excel类型");
            }
//            DataDict dataDict = dataDictService.findChildrenByPrimaryKey("MCHNT_IMPORT_PARAM", BusinessContainer.SYS_IMPORT_EXPORT_PARAM);
            UpmpSysParam dataDict = upmpSysParamService.findChildrenByPrimaryKeyAndParent("MCHNT_IMPORT_PARAM",
                    BusinessContainer.SYS_IMPORT_EXPORT_PARAM, InstId, null);
            if(Common.isBlank(dataDict)){
                log.error("解析文件时获取系统参数失败，请联系系统管理员");
                throw new RedpException("解析文件时获取系统参数失败，请联系系统管理员");
            }
            if(Common.isBlank(dataDict.getRichtextValue())){
                log.error("解析文件时获取系统参数值失败，请联系系统管理员");
                throw new RedpException("解析文件时获取系统参数值失败，请联系系统管理员");
            }
            Map sysparam = (Map) JSON.parse(dataDict.getRichtextValue());
            int maxRecords = Common.isBlank(sysparam.get("MAX_RECORDS"))?Integer.valueOf(extPropertyPlaceholderConfigurer.getProperty("MCHNT_IMPORT_MAX_RECORDS")):Integer.valueOf(sysparam.get("MAX_RECORDS").toString());
            ArrayList<BTxnLimitCfg> bankLevelQuotaList = new ArrayList<>();
            Workbook workbook = null;
            if (originalFilename.endsWith(".xlsx")) {
                workbook = new XSSFWorkbook(excelFile.getInputStream());
            } else if (originalFilename.endsWith(".xls")) {
                workbook = new HSSFWorkbook(excelFile.getInputStream());
            }

            Sheet sheetAt = workbook.getSheetAt(0);
            int lastRowNum = sheetAt.getLastRowNum();
            if(lastRowNum < 1){
                log.error("导入文件数据为空");
                return OperationResult.buildFailureResult("请填写商户组别限额信息再导入！");
            }
            if(maxRecords<lastRowNum){
                log.error("导入文件中限额信息记录数超过{}！",maxRecords);
                throw new RedpException("导入文件中限额信息记录数超过"+maxRecords+"！");
            }
            //校验模板是否正确
            verifyTable(sheetAt.getRow(0));
            List<IndustryInfo> mccList = bankLevelQuotaManagetService.getMCCList();
            List<McGrpInfo> mcGrpList = bankLevelQuotaManagetService.getMcGrpList();
            UpmpUserInfoVO user = RedpUpmpUtil.getCurrentUser(InstId);
            String instId = "";
            String crtOrgId = "";
            if(user.isAdmin()){
//                instId = request.getParameter("instId");
                instId=InstId;
                UpmpOrganization headOrg = iUpmpOrganizationService.getHeadOrgByCode(InstId);
                crtOrgId = headOrg == null ? user.getOrgCode() : headOrg.getOrgCode();
            }else{
                instId = user.getInstId();
                crtOrgId = user.getOrgCode();
            }
            for (int i = 1; i <= lastRowNum; i++) {
                BTxnLimitCfg bankLevelQuota = new BTxnLimitCfg();
                Row rowTitle = sheetAt.getRow(i);
                if (rowTitle != null) {// 行不为空
                    // 读取cell

                    bankLevelQuota.setGrpNo(CommonUtils.getValue(rowTitle.getCell(0)));
                    bankLevelQuota.setIndustryType(CommonUtils.getValue(rowTitle.getCell(1)));
                    bankLevelQuota.setDayLimitAmt(CommonUtils.getValue(rowTitle.getCell(2)));
                    bankLevelQuota.setMonthLimitAmt(CommonUtils.getValue(rowTitle.getCell(3)));
                    bankLevelQuota.setSingleLimitLoanMaxAmt(CommonUtils.getValue(rowTitle.getCell(4)));
                    bankLevelQuota.setDayLimitLoanAmt(CommonUtils.getValue(rowTitle.getCell(5)));
                    bankLevelQuota.setMonthLimitLoanAmt(CommonUtils.getValue(rowTitle.getCell(6)));
                    bankLevelQuota.setSingleLimitCreditMaxAmt(CommonUtils.getValue(rowTitle.getCell(7)));
                    bankLevelQuota.setDayLimitCreditAmt(CommonUtils.getValue(rowTitle.getCell(8)));
                    bankLevelQuota.setMonthLimitCreditAmt(CommonUtils.getValue(rowTitle.getCell(9)));
                    bankLevelQuota.setInstId(instId);
                    bankLevelQuota.setCrtOrgId(crtOrgId);

                    if (StringUtils.isBlank(bankLevelQuota.getGrpNo())) {
                        throw new RedpException("数据非空校验不通过");
                    }

                    verfiyData(bankLevelQuota);
                    verfiyMcGrpMCC( bankLevelQuota,mcGrpList,mccList);
                    bankLevelQuotaList.add(bankLevelQuota);
                }
            }
            bankLevelQuotaManagetService.batchUploadBankQuotal(bankLevelQuotaList,instId);
            return OperationResult.buildSuccessResult("数据导入成功");
        }catch (Exception e) {
            return OperationResult.buildFailureResult(e.getMessage());
        }
    }
    private void verfiyMcGrpMCC(BTxnLimitCfg bankLevelQuota,List<McGrpInfo> mcGrpList,List<IndustryInfo> mccList) throws RedpException {

        UpmpUserInfoVO user = RedpUpmpUtil.getCurrentUser(bankLevelQuota.getInstId());
        String instId = user.getInstId();
        String grpNo = bankLevelQuota.getGrpNo();
        String industryType = bankLevelQuota.getIndustryType();
        if(StringUtils.isNotBlank(grpNo)&&StringUtils.isNotBlank(industryType)){
            for(IndustryInfo e : mccList){
                if(industryType.equals(e.getIndustryType())){
                    return ;
                }
            };
            throw new RedpException("该MCC信息不存在:"+industryType);
        }else if(StringUtils.isNotBlank(grpNo)&&StringUtils.isBlank(industryType)){
            for(McGrpInfo e : mcGrpList){
                if(grpNo.equals(e.getGrpNo())){
                    return ;
                }
            };
            throw new RedpException("该组别信息不存在:"+grpNo);

        }else {
            throw new RedpException("数据不匹配");
        }

    }
    private void verifyTable(Row row) throws RedpException {
        if (!("商户组别编号".equals(CommonUtils.getValue(row.getCell(0))))) {
            throw new RedpException("导入模板不匹配");
        }
        if(!("商户MCC编号".equals(CommonUtils.getValue(row.getCell(1))))){
            throw new RedpException("导入模板不匹配");
        }
        if (!("日累计限额".equals(CommonUtils.getValue(row.getCell(2))))) {
            throw new RedpException("导入模板不匹配");
        }
        if (!("月累计限额".equals(CommonUtils.getValue(row.getCell(3))))) {
            throw new RedpException("导入模板不匹配");
        }
        if (!("单笔借记限额".equals(CommonUtils.getValue(row.getCell(4))))) {
            throw new RedpException("导入模板不匹配");
        }
        if (!("日累计借记限额".equals(CommonUtils.getValue(row.getCell(5))))) {
            throw new RedpException("导入模板不匹配");
        }
        if (!("月累计借记限额".equals(CommonUtils.getValue(row.getCell(6))))) {
            throw new RedpException("导入模板不匹配");
        }
        if (!("单笔贷记限额".equals(CommonUtils.getValue(row.getCell(7))))) {
            throw new RedpException("导入模板不匹配");
        }
        if (!("日累计贷记限额".equals(CommonUtils.getValue(row.getCell(8))))) {
            throw new RedpException("导入模板不匹配");
        }
        if (!("月累计贷记限额".equals(CommonUtils.getValue(row.getCell(9))))) {
            throw new RedpException("导入模板不匹配");
        }

    }
}
